Skip to main content

All Questions

Tagged with
-1votes
1answer
39views

In a three nested for loop with labeled break, why is the output the same when the labeled break is positioned in the inner and middle loop?

Why is the output exactly the same when the labeled break is positioned before the start of the middle and inner loop? Example code 1 - When break point is positioned at the start of the inner loop ...
Rupesh Pradhan's user avatar
0votes
1answer
285views

nested For Loops in Java

Currently struggling to get my head around nested Loops. Having some trouble completing this exercise and just wanted to know where I'm going wrong. Exercise: In Tad's postal service, each PO box is ...
Oliver Madge's user avatar
0votes
1answer
68views

Discrepancy in behaviour for similar java code when trying to access element from a list

I was trying to solve a coding problem https://www.hackerrank.com/challenges/minimum-distances/problem (Given a list find the minimum distance between any two equal elements) Wrote this code, which ...
manofaction's user avatar
0votes
0answers
82views

Changing a nested loop to print elements differently

I have this nested loop. for (Fencerss fencer1 : team1.getFencers()) { for (Fencerss fencer2 : team2.getFencers()) { PdfPCell cell1 = new PdfPCell(new Phrase(fencer1.getName() + " &...
Moustafa Amr's user avatar
2votes
3answers
117views

Filling 2D array diagonally

I've been trying to get a 10x10 2D array filled diagonally as in the image below for a couple hours now, but after checking every possible way to use rows and columns I still can't seem to identify my ...
blackburrow112's user avatar
-1votes
4answers
102views

3 nested for-each loops as Java stream

On the project I am currently working on, we have this construct of three nested for loops: final Vector3i startPos = new Vector3i(-3, -2, -3); final Vector3i finishPos = new Vector3i(3, 4, 3); final ...
Ancient Darth's user avatar
-1votes
4answers
75views

Hourglass code logic error using nested for loops

I'm working on a assignment where I need to print our an hourglass using nested for loops. The input base number(number of initial quotation marks) is user inputed, and odd and even difference is that ...
Babette's user avatar
-4votes
1answer
230views

How do I make a boolean variable that is true if it is divisible by any odd number greater than 1 (including possibly itself), and false otherwise? [closed]

I need to create a boolean variable called hasOddFactor that is true if num is divisible by any odd number greater than 1 (including possibly itself), and false otherwise. The current code that I can ...
Sheebs's user avatar
0votes
1answer
54views

Creating a Christmas Tree with proper spacing with the trunk and base under the leaves

I just can't seem to space the trunk and base of my christmas tree. The trunk and base are a fixed value and they have to be centered for any values given for the tree leaves. I tried doing this ...
KEVIN CAI CRACK123's user avatar
1vote
1answer
51views

How to display a table dynamically in Thymleaf with Java?

How can I display a table in HTML code using Thymleaf and Java? Backend: (I created a HTML Template with TemplateEngine) private Map<String, Object> createAdditionalContext() { Map<String, ...
Roland Tömösközi's user avatar
0votes
2answers
1kviews

Java: How can I fix this nested loops

Integer inputNum is read from input. For each number from 1 to inputNum, output the number followed by the number's value of hashtag characters ('#'). End each output with a newline. Ex: If the input ...
El36's user avatar
0votes
2answers
44views

Deleting upper left triangle from multiplication table

I'm new to programming and am taking an intro to programming class which focuses on java. I have an assignment that have been working on but can't seem to get the last portion of the requirements. I ...
omarviz's user avatar
0votes
2answers
88views

A simple Java loop does not work as intended [closed]

In Java, each number is associated with a character. For example: int ch = 65; System.out.print((char)(ch)); // output: A Similarly, System.out.print((char)(66)); // output: B and so on This is my ...
Akshat Mishra's user avatar
0votes
1answer
112views

generating a nth prime number without using 'isprime()' function

there is no output for the code when the input exceeds two. import java.util.Scanner; class PrimeNumberFinder { static boolean is_prime(int number ,int[] prime_numbers) { boolean is_prime =...
Pranshu's user avatar
-1votes
1answer
88views

problem storing high score for a number guessing game in java

I'm having problems storing the high score of the game with multiple players who each have a different name and score. no matter the players score, the code outputs that they beat the high score. the ...
chickenrice22's user avatar

153050per page
close